<?php
/* 类型属性视图模型
* @Author: Jerry-chen
* @Date:   2014-07-08 01:18:55
* @Last Modified time: 2014-07-12 22:31:05
* @Last Modified by: Jerry-chen<uranusbill@163.com>
* @ Copyright (c) 2014 http://www.cooldreamer.com All rightsreserved.
*/

class TypeattrViewModel extends ViewModel
{
	//定义主表
	public $table = 'type';
	//定义关联表信息
	public $view = array(

		//定义attr表规则
			'attr' => array(
				//指定连接方式
				'type'	=> INNER_JOIN,
				//关联条件
				'on'	=> 'type.typeid = attr.typeid'
			),
		);
	/**
	 * [get_all 获得关联表的信息]
	 * @return [type] [description]
	 */
	public function get_all($where=null)
	{
		return $this->where($where)->all();
	}
	/**
	 * [get_one 获得一条数据]
	 * @param  [type] $where [description]
	 * @param  [type] $field [description]
	 * @return [type]        [description]
	 */
	public function get_one($where=null,$field=null)
	{
		return $this->where($where)->field($field)->find();
	}
}

?>
